package org.example.model;

import java.time.Instant;

public class Session {
    private final String sessionKey;
    private final int customerId;
    private final Instant expiryTime;

    public Session(String sessionKey, int customerId, Instant expiryTime) {
        this.sessionKey = sessionKey;
        this.customerId = customerId;
        this.expiryTime = expiryTime;
    }

    // Getters
    public String getSessionKey() { return sessionKey; }
    public int getCustomerId() { return customerId; }
    public Instant getExpiryTime() { return expiryTime; }

    /**
     * 检查会话是否有效（使用当前时间）
     */
    public boolean isValid() {
        return Instant.now().isBefore(expiryTime);
    }

    /**
     * 检查会话在特定时间点是否有效
     */
    public boolean isValid(Instant instant) {
        return instant.isBefore(expiryTime);
    }

    @Override
    public String toString() {
        return null;
    }

    public void updateLastAccessed() {
    }
}